package com.youhome.report.controller;

import com.youhome.common.enums.ZilLowSearchTypeEnum;
import com.youhome.common.enums.ZillowTypeEnum;
import com.youhome.common.exception.CustomException;
import com.youhome.service.model.ListHub;
import com.youhome.service.model.ZipCode;
import com.youhome.service.response.TimeValueItemResult;
import com.youhome.service.service.ListHubService;
import com.youhome.service.service.ReportZilLowService;
import com.youhome.service.service.ZilLowByCityService;
import com.youhome.service.service.ZipCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Locale;

/**
 * Created by chen365 on 2019/05/27.
 */
@Controller
@RequestMapping(value = "/test")
public class TestController {
    @Autowired
    private ReportZilLowService reportZilLowService;
    @Autowired
    private ZipCodeService zipCodeService;
    @Autowired
    private ZilLowByCityService zilLowByCityService;
    @Autowired
    private ListHubService listHubService;

    @GetMapping(value = "/zillow")
    public String zillow(Model model, String zip,
                         @RequestParam(value = "dataType", defaultValue = "zip") String dataType,
                         @RequestParam(value = "year", defaultValue = "0") Integer year) {
        //ListHub listHub = listHubService.selectByPrimaryKey(id);
        ZipCode zipCode = zipCodeService.selectShortByPrimaryKey(zip);


        Locale locale = LocaleContextHolder.getLocale();

        System.err.println("Locale:"+Locale.getDefault().getLanguage());


        /*
        //买卖指数 non-time
        reportZilLowService.buyer_seller_index(model, zipCode, dataType, year);

        //滑动平均值销售存量 time
        reportZilLowService.inventory_measure_ssa_public(model, zipCode, dataType, year);

        //销售存量 time
        reportZilLowService.inventory_measure_public(model, zipCode, dataType, year);

        //市场健康指数 non-time
        reportZilLowService.market_health_index(model, zipCode, dataType, year);

        //降价幅度比例-全部 time
        reportZilLowService.listings_price_cut_seas_adj_all_homes(model, zipCode, dataType, year);

        //降价幅度比例-公寓 time
        reportZilLowService.listings_price_cut_seas_adj_condominum(model, zipCode, dataType, year);

        //降价幅度比例-独栋 time
        reportZilLowService.listings_price_cut_seas_adj_single_family_residence(model, zipCode, dataType, year);

        //降价幅度金额-全部 time
        reportZilLowService.median_price_cut_dollar_all_homes(model, zipCode, dataType, year);

        //降价幅度金额-公寓 time
        reportZilLowService.median_price_cut_dollar_condominum(model, zipCode, dataType, year);

//        10	Median_PriceCut_Dollar_SingleFamilyResidence.csv	降价幅度金额-独栋	time
        reportZilLowService.median_price_cut_dollar_single_family_residence(model, zipCode, dataType, year);

//        11	MedianListingPrice_1Bedroom.csv	上市价格-单卧	time
        reportZilLowService.median_listing_price_1bedroom(model, zipCode, dataType, year);

//        12	MedianListingPrice_2Bedroom.csv	上市价格-双卧	time
        reportZilLowService.median_listing_price_2bedroom(model, zipCode, dataType, year);

//        13	MedianListingPrice_3Bedroom.csv	上市价格-三卧	time
        reportZilLowService.median_listing_price_3bedroom(model, zipCode, dataType, year);

//        14	MedianListingPrice_4Bedroom.csv	上市价格-四卧	time
        reportZilLowService.median_listing_price_4bedroom(model, zipCode, dataType, year);

//        15	MedianListingPrice_5BedroomOrMore.csv	上市价格-五卧或以上	time
        reportZilLowService.median_listing_price_5bedroom_or_more(model, zipCode, dataType, year);

//        16	MedianListingPrice_AllHomes.csv	上市价格-全部	time
        reportZilLowService.median_listing_price_all_homes(model, zipCode, dataType, year);

//        17	MedianListingPrice_CondoCoop.csv	上市价格-公寓	time
        reportZilLowService.median_listing_price_condo_coop(model, zipCode, dataType, year);

//        18	MedianListingPrice_DuplexTriplex.csv	上市价格-联式	time
        reportZilLowService.median_listing_price_duplex_triplex(model, zipCode, dataType, year);

//        19	MedianListingPrice_Sfr.csv	上市价格-独栋	time
        reportZilLowService.median_listing_price_sfr(model, zipCode, dataType, year);

//        20	MedianListingPricePerSqft_1Bedroom.csv	上市面积均价-单卧	time
        reportZilLowService.median_listing_price_per_sqft_1bedroom(model, zipCode, dataType, year);

//        21	MedianListingPricePerSqft_2Bedroom.csv	上市面积均价-双卧	time
        reportZilLowService.median_listing_price_per_sqft_2bedroom(model, zipCode, dataType, year);

//        22	MedianListingPricePerSqft_3Bedroom.csv	上市面积均价-三卧	time
        reportZilLowService.median_listing_price_per_sqft_3bedroom(model, zipCode, dataType, year);

//        23	MedianListingPricePerSqft_4Bedroom.csv	上市面积均价-四卧	time
        reportZilLowService.median_listing_price_per_sqft_4bedroom(model, zipCode, dataType, year);

//        24	MedianListingPricePerSqft_5BedroomOrMore.csv	上市面积均价-五卧	time
        reportZilLowService.median_listing_price_per_sqft_5bedroom_or_more(model, zipCode, dataType, year);

//        25	MedianListingPricePerSqft_AllHomes.csv	上市面积均价-全部	time
        reportZilLowService.median_listing_price_per_sqft_all_homes(model, zipCode, dataType, year);

//        26	MedianListingPricePerSqft_CondoCoop.csv	上市面积均价-公寓	time
        reportZilLowService.median_listing_price_per_sqft_condo_coop(model, zipCode, dataType, year);

//        27	MedianListingPricePerSqft_DuplexTriplex.csv	上市面积均价-联式	time
        reportZilLowService.median_listing_price_per_sqft_duplex_triplex(model, zipCode, dataType, year);

//        28	MedianListingPricePerSqft_Sfr.csv	上市面积均价-独栋	time
        reportZilLowService.median_listing_price_per_sqft_sfr(model, zipCode, dataType, year);



//        29	MedianPctOfPriceReduction_AllHomes.csv	房屋价格下调统计-全部	time
        reportZilLowService.median_pct_of_price_reduction_all_homes(model, zipCode, dataType, year);

//        30	MedianPctOfPriceReduction_Condominum.csv	房屋价格下调统计-公寓	time
        reportZilLowService.median_pct_of_price_reduction_condominum(model, zipCode, dataType, year);

//        31	MedianPctOfPriceReduction_SingleFamilyResidence.csv	房屋价格下调统计-独栋	time
        reportZilLowService.median_pct_of_price_reduction_single_family_residence(model, zipCode, dataType, year);


//        32	MedianRentalPrice_1Bedroom.csv	租金收入-单卧	time
        reportZilLowService.median_rental_price_1bedroom(model, zipCode, dataType, year);
//        33	MedianRentalPrice_2Bedroom.csv	租金收入-双卧	time
        reportZilLowService.median_rental_price_2bedroom(model, zipCode, dataType, year);
//        34	MedianRentalPrice_3Bedroom.csv	租金收入-三卧	time
        reportZilLowService.median_rental_price_3bedroom(model, zipCode, dataType, year);
//        35	MedianRentalPrice_4Bedroom.csv	租金收入-四卧	time
        reportZilLowService.median_rental_price_4bedroom(model, zipCode, dataType, year);
//        36	MedianRentalPrice_5BedroomOrMore.csv	租金收入-五卧或以上	time
        reportZilLowService.median_rental_price_5bedroom_or_more(model, zipCode, dataType, year);
//        37	MedianRentalPrice_AllHomes.csv	租金收入-全部	time
        reportZilLowService.median_rental_price_all_homes(model, zipCode, dataType, year);
//        38	MedianRentalPrice_CondoCoop.csv	租金收入-公寓	time
        reportZilLowService.median_rental_price_condo_coop(model, zipCode, dataType, year);
//        39	MedianRentalPrice_DuplexTriplex.csv	租金收入-联式	time
        reportZilLowService.median_rental_price_duplex_triplex(model, zipCode, dataType, year);
//        40	MedianRentalPrice_Mfr5Plus.csv	租金收入-多户	time
        reportZilLowService.median_rental_price_mfr_5plus(model, zipCode, dataType, year);
//        41	MedianRentalPrice_Sfr.csv	租金收入-独栋	time
        reportZilLowService.median_rental_price_sfr(model, zipCode, dataType, year);
//        42	MedianRentalPrice_Studio.csv	租金收入-独间	time
        reportZilLowService.median_rental_price_studio(model, zipCode, dataType, year);


//        43	MedianRentalPricePerSqft_1Bedroom.csv	租金面积均价-单卧	time
        reportZilLowService.median_rental_price_per_sqft_1bedroom_result(model, zipCode, dataType, year);
//        44	MedianRentalPricePerSqft_2Bedroom.csv	租金面积均价-双卧	time
        reportZilLowService.median_rental_price_per_sqft_2bedroom_result(model, zipCode, dataType, year);
//        45	MedianRentalPricePerSqft_3Bedroom.csv	租金面积均价-三卧	time
        reportZilLowService.median_rental_price_per_sqft_3bedroom_result(model, zipCode, dataType, year);
//        46	MedianRentalPricePerSqft_4Bedroom.csv	租金面积均价-四卧	time
        reportZilLowService.median_rental_price_per_sqft_4bedroom_result(model, zipCode, dataType, year);
//        47	MedianRentalPricePerSqft_5BedroomOrMore.csv	租金面积均价-五卧或以上	time
        reportZilLowService.median_rental_price_per_sqft_5bedroom_or_more_result(model, zipCode, dataType, year);
//        48	MedianRentalPricePerSqft_AllHomes.csv	租金面积均价-全部	time
        reportZilLowService.median_rental_price_per_sqft_all_homes_result(model, zipCode, dataType, year);
//        49	MedianRentalPricePerSqft_CondoCoop.csv	租金面积均价-公寓	time
        reportZilLowService.median_rental_price_per_sqft_condo_coop_result(model, zipCode, dataType, year);
//        50	MedianRentalPricePerSqft_DuplexTriplex.csv	租金面积均价-联式	time
        reportZilLowService.median_rental_price_per_sqft_duplex_triplex_result(model, zipCode, dataType, year);
//        51	MedianRentalPricePerSqft_Mfr5Plus.csv	租金面积均价-多户	time
        reportZilLowService.median_rental_price_per_sqft_mfr_5plus_result(model, zipCode, dataType, year);
//        52	MedianRentalPricePerSqft_Sfr.csv	租金面积均价-独栋	time
        reportZilLowService.median_rental_price_per_sqft_sfr_result(model, zipCode, dataType, year);
//        53	MedianRentalPricePerSqft_Studio.csv	租金面积均价-独间	time
        reportZilLowService.median_rental_price_per_sqft_studio_result(model, zipCode, dataType, year);


//        54	MedianValuePerSqft_AllHomes.csv	房屋面积估值-全部	time
        reportZilLowService.median_value_per_sqft_all_homes_result(model, zipCode, dataType, year);
//        55	PctOfHomesDecreasingInValues_AllHomes.csv	房屋估值下调统计-全部	time
        reportZilLowService.pct_of_homes_decreasing_in_values_all_homes_result(model, zipCode, dataType, year);
//        56	PctOfHomesIncreasingInValues_AllHomes.csv	房屋估值上升统计-全部	time
        reportZilLowService.pct_of_homes_increasing_in_values_all_homes_result(model, zipCode, dataType, year);
//        57	PctOfListingsWithPriceReductions_AllHomes.csv	上市价格下调统计-全部	time
        reportZilLowService.pct_of_listings_with_price_reductions_all_homes_result(model, zipCode, dataType, year);
//        58	PctOfListingsWithPriceReductions_Condominum.csv	上市价格下调统计-公寓	time
        reportZilLowService.pct_of_listings_with_price_reductions_condominum_result(model, zipCode, dataType, year);
//        59	PctOfListingsWithPriceReductions_SingleFamilyResidence.csv	上市价格下调统计-独栋	time
        reportZilLowService.pct_of_listings_with_price_reductions_single_family_residence_result(model, zipCode, dataType, year);
//        60	PriceToRentRatio_AllHomes.csv	租售比-全部	time
        reportZilLowService.price_to_rent_ratio_all_homes_result(model, zipCode, dataType, year);


//        61	Zhvi_1bedroom.csv	房屋价格指数-单卧	time
        reportZilLowService.zhvi_1bedroom_result(model, zipCode, dataType, year);
//        62	Zhvi_2bedroom.csv	房屋价格指数-双卧	time
        reportZilLowService.zhvi_2bedroom_result(model, zipCode, dataType, year);
//        63	Zhvi_3bedroom.csv	房屋价格指数-三卧	time
        reportZilLowService.zhvi_3bedroom_result(model, zipCode, dataType, year);
//        64	Zhvi_4bedroom.csv	房屋价格指数-四卧	time
        reportZilLowService.zhvi_4bedroom_result(model, zipCode, dataType, year);
//        65	Zhvi_5BedroomOrMore.csv	房屋价格指数-五卧或以上	time
        reportZilLowService.zhvi_5bedroom_or_more_result(model, zipCode, dataType, year);
//        66	Zhvi_AllHomes.csv	房屋价格指数-全部	time
        reportZilLowService.zhvi_all_homes_result(model, zipCode, dataType, year);
//        67	Zhvi_BottomTier_yoy.csv	房屋价格指数-底层-年化同比	time
        reportZilLowService.zhvi_bottom_tier_yoy_result(model, zipCode, dataType, year);
//        68	Zhvi_BottomTier.csv	房屋价格指数-底层	time
        reportZilLowService.zhvi_bottom_tier_result(model, zipCode, dataType, year);
//        69	Zhvi_Condominum.csv	房屋价格指数-公寓	time
        reportZilLowService.zhvi_condominum_result(model, zipCode, dataType, year);
//        70	Zhvi_MiddleTier_yoy.csv	房屋价格指数-中层-年化同比	time
        reportZilLowService.zhvi_middle_tier_yoy_result(model, zipCode, dataType, year);
//        71	Zhvi_MiddleTier.csv	房屋价格指数-中层	time
        reportZilLowService.zhvi_middle_tier_result(model, zipCode, dataType, year);
//        72	Zhvi_SingleFamilyResidence.csv	房屋价格指数-独栋	time
        reportZilLowService.zhvi_single_family_residence_result(model, zipCode, dataType, year);
//        73	Zhvi_Summary_AllHomes.csv	房屋价格指数-全部	time
        reportZilLowService.zhvi_summary_all_homes_result(model, zipCode, dataType, year);
//        74	Zhvi_TopTier_yoy.csv	房屋价格指数-顶层-年化同比	time
        reportZilLowService.zhvi_top_tier_yoy_result(model, zipCode, dataType, year);
//        75	Zhvi_TopTier.csv	房屋价格指数-顶层	time
        reportZilLowService.zhvi_top_tier_result(model, zipCode, dataType, year);



//        76	Zri_AllHomes_Summary.csv	房屋租金指数-全部-汇总	non-time
        reportZilLowService.zri_all_homes_summary_result(model, zipCode, dataType, year);
//        77	Zri_AllHomes.csv	房屋租金指数-全部	time
        reportZilLowService.zri_all_homes_result(model, zipCode, dataType, year);
//        78	Zri_AllHomesPlusMultifamily_Summary.csv	房屋租金指数-全部加多户-汇总	non-time
        reportZilLowService.zri_all_homes_plus_multifamily_summary_result(model, zipCode, dataType, year);
//        79	Zri_AllHomesPlusMultifamily.csv	房屋租金指数-全部加多户	time
        reportZilLowService.zri_all_homes_plus_multifamily_result(model, zipCode, dataType, year);
//        80	Zri_MultiFamilyResidenceRental_Summary.csv	房屋租金指数-多户-汇总	non-time
        reportZilLowService.zri_multifamily_residence_rental_summary_result(model, zipCode, dataType, year);
//        81	Zri_MultiFamilyResidenceRental.csv	房屋租金指数-多户	time
        reportZilLowService.zri_multifamily_residence_rental_result(model, zipCode, dataType, year);
//        82	Zri_SingleFamilyResidenceRental_Summary.csv	房屋租金指数-独栋-汇总	non-time
        reportZilLowService.zri_single_family_residence_rental_summary_result(model, zipCode, dataType, year);
//        83	Zri_SingleFamilyResidenceRental.csv	房屋租金指数-独栋	time
        reportZilLowService.zri_single_family_residence_rental_result(model, zipCode, dataType, year);
//        84	ZriPerSqft_AllHomes.csv	房屋面积平均租金-全部	time
        reportZilLowService.zri_per_sqft_all_homes_result(model, zipCode, dataType, year);



        //2018-10-26 新增
        //85. BreakEven_PR_2018-03 租售比   non-time
        reportZilLowService.breakeven_pr_result(model, zipCode, dataType, year);


        //86. Affordability_Wide_Public 贷款能力
        reportZilLowService.mortgage_affordability_result(model, zipCode, dataType, year);


        //87. Affordability_Wide_Public 价格收入比
        reportZilLowService.price_to_income_result(model, zipCode, dataType, year);
        //88. Affordability_Wide_Public 租金能力
        reportZilLowService.rent_affordability_result(model, zipCode, dataType, year);


        //89. ZriForecast_Public 租金涨幅百分比预测
        reportZilLowService.zri_forecast_public_result(model, zipCode, dataType, year);
        //90. SaleToListRatio_City 卖房成功比例  按城市统计
        reportZilLowService.sale_to_list_ratio_city_result(model, zipCode, dataType, year);
        //91. DaysOnZillow_City 中位挂牌时间 以城市为准
        reportZilLowService.days_on_market_city_result(model, zipCode, dataType, year);
        //92. MedianListingPrice_BottomTier	低端房产中位标价
        reportZilLowService.median_listing_price_bottom_tier_result(model, zipCode, dataType, year);


        //93. MedianListingPrice_TopTier 高端房产中位标价
        reportZilLowService.median_listing_price_top_tier_result(model, zipCode, dataType, year);
        //94. Sale_Counts_Zip	房产销售数量 按zip统计
        reportZilLowService.sale_counts_result(model, zipCode, dataType, year);
        //95. Sale_Counts_Seas_Adj_City 房产销售数量 按city统计
        reportZilLowService.sale_counts_seas_adj_city_result(model, zipCode, dataType, year);
        //96. Sale_Prices_Zip 所有房产中位售价
        reportZilLowService.sale_prices_result(model, zipCode, dataType, year);

        //97. MortgageRateJumboFixed 超大贷款利息
        reportZilLowService.mortgage_rate_jumbo_fixed_result(model, zipCode, dataType, 1);
        //98. MortgageRateConventionalFixed 传统贷款利息
        reportZilLowService.mortgage_rate_conventional_fixed_result(model, zipCode, dataType, 1);

        //99. InventoryMeasure_Tiers_Metro_Public 存量房
        reportZilLowService.inventory_measure_tiers_metro_public_count_result(model, zipCode, dataType, year); //数量
        reportZilLowService.inventory_measure_tiers_metro_public_pct_result(model, zipCode, dataType, year); //百分比

        //100. Metro_NETiers_2017Q4 负资产率 大都会
        reportZilLowService.negative_equity_metro_result(model, zipCode, dataType, year);//文字
        //101. NegativeEquity_2017Q4_Public 负资产率 城市
        reportZilLowService.negative_equity_city_result(model, zipCode, dataType, year); //百分比

        // 102. MonthlyTurnover_Zip 房产换手率
        reportZilLowService.monthly_turnover_result(model, zipCode, dataType, year); //房产换手率
        // 103. ForeclosuresPer10Khomes_Zip 法拍房比例
        reportZilLowService.foreclosures_per_10k_homes_result(model, zipCode, dataType, year); //法拍房比例
        //104. Affordability_Income 中位家庭收入 按都会区统计
        reportZilLowService.affordability_income_result(model, zipCode, dataType, year);

        */
        return "zillow";
    }
}
